<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<meta content="caibaojian" name="author" />
		<title>小立到家</title>
		<link rel="stylesheet" href="css/master_share.css">
		<style type="text/css">
			body,
			html {
				background-color: #FFD042;
			}
			.content{
				position: relative;
				height: 667px;
				background: url(img/share_bcimg1.png) no-repeat center;
				background-size: 100% 100%;
			}
			
			.bg {
				background-size: 100% 100%;
				color: #ffffff;
				text-align: center;
			}
			
			.bg h1 {
				font-size: 0.7rem;
				padding: 1.26rem 0 0.56rem 0;
			}
			
			.bg p {
			}
			
			.title_p {
				font-size: 0.32rem;
				color: #515151;
				text-align: center;
			}
			.new_img{
				padding-top: 3.8rem;
				display: block;
				margin: 0 auto;
				width: 80%;
			}
			input::-webkit-input-placeholder{
			        color: #ccc;
			}
			input::-moz-placeholder{ 
			        color: #ccc;        
			}
			input::-ms-input-placeholder{ 
			        color: #ccc;        
			}
			
			.rel_box{
				position: absolute;
				top: 14.5rem;
				width: 100%;
			}
			
			button {
				display: block;
				width: 5.91rem;
				height: 0.9rem;
				margin: 0 auto;
				border-radius: 1.2rem;
				border: none;
				color: #9a742e;
				line-height: 0.9rem;
				text-align: center;
				background: transparent;
			}
			.title_p_big{
				font-size: 0.6rem;
				color: #333;
				font-weight: 600;
			}
			.title_p_line{
				width: 1rem;
				margin: 0.6rem auto;
			}
			.title_p_code{
				color: #FF7741;
				font-size: 0.52rem;
			}
			.input {
				display: block;
				width: 9.52rem;
				height: 1.6rem;
				border-radius: 0.8rem;
				text-indent: 0.3rem;
				margin: 0.3rem auto 0;	
				border: 1px solid transparent ;
				overflow: hidden;
				background: #FFF;
				display: flex;
				align-items: center;
			}
			.input input{
				padding-left: 0.4rem;
				width: 100%;
				height: 100%;
				border: none;
				background: transparent ;
				font-size: 0.56rem;
			}
			input:focus{   
				border:none;
			}
			.input .login_input2{
				width: 60%;
			}
			.getReg{
				height: 100%;
				width: 40%;
				color: #FF7D44;	
			}
			.registerbtn{
				width: 195px;
				height: 40px;
				color: transparent;
				background: url(img/164bnkn1.png) no-repeat center;
				background-size: 100% 100%;
			}
			.input1{
				display: block;
				padding: .2rem 0;
				padding-top: 0;
				width: 9rem;
				text-indent: 0.3rem;
				margin: 0.4rem auto;	
				overflow: hidden;
			}
			.input11{
				display: flex;
				align-items: center;
				margin: .3rem 0;
				padding: .2rem .8rem;
				color: #555;
				font-size: .6rem;
				background-color: #FFF;
				border-radius: .3rem;
			}
			
			
		</style>
		<script src="js/jquery.js"></script>
		<script type="text/javascript">
			function setfont() {
				var num = 1 / window.devicePixelRatio;
				var fontSize = document.documentElement.clientWidth / 15;
				document.getElementsByTagName('html')[0].style.fontSize = fontSize + 'px';
			}
			(function() {
				setfont()
			})()
			window.onresize = function() {
				setfont()
			}
		</script>
	</head>

	<body>
		<div class="content bg">
			<div class="rel_box">
				<form action="" class="formadd"> 
					<div class="input">
						<input type="tel" name="name" class=" login_input f_15" autocomplete="off" placeholder="请输入您的姓名">
					</div>
					<div class="input">
						<input type="tel" name="mobile" class=" login_input f_15" autocomplete="off" placeholder="请输入您的电话">
					</div>
					
					<div class="input1">
						<label class="input11" style="margin-top: 0;">
							<input name="service_type" type="checkbox" value="1" />
							<div>安装</div>
						</label>
						<label class="input11">
							<input name="service_type" type="checkbox" value="2" />
							<div>维修</div>
						</label>
						<label class="input11">
							<input name="service_type" type="checkbox" value="3" />
							<div>保洁</div>
						</label>
					</div>
					
					<button type="button" class="registerbtn" onclick="smsLogin()"></button>
				</form> 
			</div>
		</div>
	</body>
	<script>
		var telReg = /^1[0-9]{10}$/,
			toggle = true,
			i = 60,
			host = 'https://api.aideapi.com/api/router/',
			host_configure = '?app_id=LG_APP&secret_id=LGAPP7b7041c45688932168065c33723&secret_key=3f4511c9ff9c4c04b03781e3df19c82flgapp',
			userreg = host + 'user.reg' + host_configure + '&client=1',
			getsmscode = host + 'system.smscode' + host_configure;
			
			// 获取邀请人信息
			query_recommend = 'https://api.aideapi.com/api/router/recommend.query?app_id=LG_APP&secret_id=LGAPP7b7041c45688932168065c33723&secret_key=3f4511c9ff9c4c04b03781e3df19c82flgapp';
			
			
		function getParam(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
			var r = window.location.search.substr(1).match(reg); //匹配目标参数
			if(r != null) return unescape(r[2]);
			return null; //返回参数值
		}

		var recommend = getParam("recommend")
		
		// initdata(recommend)
		
		$('#recommend').html(recommend)
		
		function initdata(recommend) {
			$.ajax({
				url: query_recommend,
				type: 'get',
				// contentType: "application/x-www-form-urlencoded",
				data: {
					recommend: recommend,
				},
				dataType: 'json',
				success: function(res) {
					if(res.code == 0) {
						if(res.member){
							if(res.member.data.name){
								$('#recommend-name').html(res.member.data.name)
							}
						}
						
						
					} else {
						// alert(result.msg);
						return;
					}
				},
				error: function(result) {
					alert("服务器繁忙，请重试！");
				}
			})
		}
		
		
		function get_code(self) {
			if($('input[name=mobile]').val().replace(/\s/g, '') == '' || !telReg.test($('input[name=mobile]').val().replace(/\s/g, ''))) {
				alert('请输入正确的手机号');
				return;
			} else {
				if(toggle) {
					$(self).attr('disabled', 'disabled')
					$.ajax({
						url: getsmscode,
						type: 'post',
						contentType: "application/x-www-form-urlencoded",
						data: {
							mobile: $('input[name=mobile]').val(),
						},
						dataType: 'json',
						success: function(res) {
							if(res.code == 0) {
								toggle = false;
								$('.getReg').html('60s');
								timEnd = setInterval(function() {
									if(i > 1) {
										i--;
										$('.getReg').html(i + 's');
									} else {
										clearInterval(timEnd);
										$('.getReg').html('获取验证码');
										i = 60;
										toggle = true;
										$(self).removeAttr('disabled')
									}
								}, 1000);
							} else {
								alert(result.msg);
								$(self).removeAttr('disabled')
								return;
							}
						},
						error: function(result) {
							console.log('737 ajaxError' + JSON.stringify(result));
							alert("服务器繁忙，请重试！");
							toggle = false;
							$('.getReg').html('60s');
							timEnd = setInterval(function() {
								if(i > 1) {
									i--;
									$('.getReg').html(i + 's');
								} else {
									clearInterval(timEnd);
									$('.getReg').html('获取验证码');
									i = 60;
									toggle = true;
									$(self).removeAttr('disabled')
								}
							}, 1000);
						}
					})
				} else {
					return;
				}
			}
		}

		function smsLogin() {
			// var clientid = "";
			// var loginInfo = {
			// 	mobile: $('input[name=mobile]').val(),
			// 	smscode: $('input[name=smscode]').val(),
			// 	code: $('input[name=code]').val(),
			// 	recommend: recommend
			// };
			// if(!telReg.test(loginInfo.mobile.replace(/\s/g, ''))) {
			// 	alert('请输入正确的手机号码')
			// 	return;
			// } else if(!loginInfo.smscode) {
			// 	alert('请输入验证码不能为空')
			// 	return;
			// } else if(!loginInfo.code) {
			// 	alert('请输入密码')
			// 	return;
			// } else {
			// 	$.ajax({
			// 		url: userreg,
			// 		type: 'post',
			// 		data: loginInfo,
			// 		dataType: 'json',
			// 		success: function(res) {
			// 			if(res.code == 0) {
			// 				alert('注册成功');
			// 				location.href = "down.html";
			// 			} else {
			// 				alert(res.msg);
			// 			}
			// 		},
			// 		error: function(result) {
			// 			alert("服务器繁忙，请重试！");
			// 		}
			// 	})
			// }
			
			
			$.fn.serializeObject = function() {  
				
				var o = {};  
			    var a = this.serializeArray();
				
			    $.each(a, function() {  
			        if (o[this.name]) {  
			            if (!o[this.name].push) {  
			                o[this.name] = [ o[this.name] ];  
			            }  
			            o[this.name].push(this.value || '');  
			        } else {  
			            o[this.name] = this.value || '';  
			        }  
			    });  
			    return o;  
			}
			
			var _data = $('.formadd').serializeObject()
			
			if(_data.service_type){
				_data.service_type = _data.service_type.join()
			}
			
			console.log(_data)
			// var json = [];
			// $(".formadd").each(function(){
			// 	json = $(this).serializeObject())
			// })
		}
	</script>
</html>